package com.qaml.mes.device.controller;


import com.earth.output.OutputMessage;
import com.earth.page.PageResponse;
import com.qaml.mes.device.api.CheckUpkeepMessageService;
import com.qaml.mes.device.dto.eqp.CheckUpkeepMessageDTO;
import com.qaml.mes.device.vo.eqp.CheckUpkeepMessageVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * <p>
 * 检保项目消息 前端控制器
 * </p>
 *
 * @author leikai
 * @since 2024-03-04
 */
@Api(tags = "检保项目消息")
@RestController
@RequestMapping("/check/upkeep/message")
public class CheckUpkeepMessageController {


    @Resource
    private CheckUpkeepMessageService checkUpkeepMessageService;

    @ApiOperation(value = "检保项目消息-列表查询(App)", notes = "检保项目消息-列表查询")
    @PostMapping("/list")
    public PageResponse<CheckUpkeepMessageVO> list(@RequestBody CheckUpkeepMessageDTO checkUpkeepMessageDTO) {
        return checkUpkeepMessageService.pageList(checkUpkeepMessageDTO);

    }

    @PostMapping("/updateReadStatus")
    @ApiOperation(value = "更新消息已读状态(App)", notes = "更新消息已读状态")
    public OutputMessage<String> updateReadStatus(@RequestBody CheckUpkeepMessageDTO checkUpkeepMessageDTO) {
        checkUpkeepMessageService.updateReadStatus(checkUpkeepMessageDTO);
        return OutputMessage.success("消息已读！");
    }

    @PostMapping("/readAll")
    @ApiOperation(value = "一键全部已读(App)", notes = "一键全部已读")
    public OutputMessage<String> readAll() {
        checkUpkeepMessageService.readAll();
        return OutputMessage.success("消息已读！");
    }

}
